<template>
  <ul>
    <a-button type="primary" @click="add">add</a-button>
    <li v-for="(item, index) in data" :key="index" @click="modify(index)">{{ item.name }}</li>
  </ul>
</template>

<script>
import { ref, onBeforeMount } from 'vue'
import { getUserList } from '@/api/login.js'
import { divide } from 'lodash'

export default {
  setup () {
    const data = ref([
      {name: '小a'},
      {name: '小b'},
      {name: '小c'},
    ])

    const add = () => {
      data.value.push({name: '小' + data.value.length + 1})
    }

    const modify = (index) => {
      data.value[index].name += '3'
    }

    const getUser = () => {
      try {
        getUserList().then(res => {
          console.log('res', res)
        })
      } catch (err) {
        throw Error(err)
      }
    }

    onBeforeMount(() => {
      // getUser()
    })

    
 
    return {
      data,
      add,
      modify,
      getUserList
    }
  }
}
</script>